package com.wgchao.authodemo.application.service.base.impl;

import com.wgchao.authodemo.application.mapstruct.dto.AgencyDTO;
import com.wgchao.authodemo.application.mapstruct.mapper.dtod.expand.AgencyMapperExpand;
import com.wgchao.authodemo.application.service.base.AgencyService;
import com.wgchao.authodemo.domian.entity.base.AgencyDO;
import com.wgchao.authodemo.domian.event.base.AgencyEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName: AgencyServiceImpl
 * @author: wgchao
 * @createTime: 2019/12/11 9:23 AM
 * @Description: TODO
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AgencyServiceImpl implements AgencyService {
    @Autowired
    private AgencyEvent agencyEvent;
    @Autowired
    private AgencyMapperExpand agencyMapper;

    @Override
    public AgencyDTO save(AgencyDTO agencyDTO) {
        AgencyDO agencyDO = agencyEvent.save(agencyMapper.toEntity(agencyDTO));
        agencyDTO = agencyMapper.toDTO(agencyDO);
        agencyDTO = agencyMapper.setParAgency(agencyDTO);
        return agencyDTO;
    }
}
